package com.atguigu.java.ai.langchain4j;

import dev.langchain4j.data.document.Document;
import dev.langchain4j.data.document.loader.FileSystemDocumentLoader;
import dev.langchain4j.data.segment.TextSegment;
import dev.langchain4j.model.embedding.EmbeddingModel;
import dev.langchain4j.store.embedding.EmbeddingStore;
import dev.langchain4j.store.embedding.EmbeddingStoreIngestor;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

@SpringBootTest
public class testUploadKnowledgeLibrary {
    @Autowired
    private  EmbeddingStore<TextSegment> embeddingStore;
    @Autowired
    private  EmbeddingModel embeddingModel;
    @Test
    public void test()   {
        List<Document> documents = FileSystemDocumentLoader.loadDocuments("D:\\0725\\笔记\\小智医疗项目\\小智医疗项目-xu\\资料\\04-科室信息");
        //文本向量化并存入向量数据库：将每个片段进行向量化，得到一个嵌入向量
        EmbeddingStoreIngestor
                .builder()
                .embeddingStore(embeddingStore)
                .embeddingModel(embeddingModel)
                .build()
                .ingest(documents);
    }
}
